package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * <h4>day01_1_springcloud_eureka</h4>
 * <p></p>
 *
 * @author : by wujianming
 * @date : 2021-11-25 22:31
 **/
@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    private IHotelService hotelList;

    //post请求
    @PostMapping("/list")
    //@RequestBody将前端传输来的json数据转化为java对象
    public PageResult list(@RequestBody RequestParams requestParams) {
       return hotelList.getPageResult(requestParams);
    }

    @PostMapping("/filters")
    public Map<String, List<String>> list1(@RequestBody RequestParams params ) throws IOException {
           return hotelList.getMap(params);
    }

    //分词器查询
    @GetMapping("/suggestion")
    public List<String> list(String key) {
       return hotelList.fenCi(key);
    }


}
